require('./Getuser.styl');

const reactMixin = require('react-mixin');
const { RadioField, Button } = SaltUI;
import { Control } from 'react-keeper'
const classnames = require('classnames')

class Getuser extends React.Component {

    constructor(props) {
        super(props);
        this.state = {
            active: props.active,
        };
        this.handleBack = this.handleBack.bind(this)
    }
    handleBack() {
        this.props.handleBack()
    }

    render() {
        const { handleBack, props: { handleSetUser } } = this;
        let radioFieldProps = {
            data: this.props.user_list,
            onChange(value, index, data) {
                handleSetUser({ name: data[index]['text'], id: data[index]['id'] })
            }
        }
        const { state: { active } } = this
        return (
            <div className={classnames("getuser", { 'active': active })}>
                <RadioField {...radioFieldProps} />
                <Button onClick={handleBack}>返回上一级</Button>
            </div>
        );
    }

    componentWillMount() {
    }

    componentDidMount() {
    }

    componentWillReceiveProps(nextProps) {
        if (this.state.active !== nextProps.active) this.setState({ active: nextProps.active })
    }

    shouldComponentUpdate(nextProps, nextState) {
        return true;
    }

    componentWillUpdate(nextProps, nextState) {
    }

    componentDidUpdate(prevProps, prevState) {
    }

    componentWillUnmount() {
    }
}


module.exports = Getuser;
